#include<bits/stdc++.h>
using namespace std;

int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n, k;
		cin>>n>>k;
		vector<int> a;
		int target;
		for(int i = 1;i <= n;i++)
		{
			int x;
			cin>>x;
			a.push_back(x);
			if(i == k)
				target = x;
		}
		sort(a.begin(), a.end());
		int idx = upper_bound(a.begin(), a.end(), target)-a.begin();
		cout<<n-idx<<endl;
	}
	return 0;
}

